package com.bj.zspace.service;

import com.bjzspace.proto.TestProto;
import com.bjzspace.proto.TestServiceGrpc;
import io.grpc.stub.StreamObserver;

public class TestServiceImpl extends TestServiceGrpc.TestServiceImplBase {

    @Override
    public void test(TestProto.TestRequest request, StreamObserver<TestProto.TestResponse> responseObserver) {
        String name = request.getName();
        System.out.println("server receive:" + name);
        System.out.println("server sleep 1s");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        TestProto.TestResponse.Builder ack_result = TestProto.TestResponse.newBuilder().setResult("ack result");
        responseObserver.onNext(ack_result.build());
        responseObserver.onCompleted();
    }
}
